﻿@using System.Diagnostics;
@using System.Collections;
@using System.Reflection;
@using System.Runtime.Versioning;
@using NewLife.Common;
@using NewLife.Cube.Extensions
@{
    //Layout = NewLife.Cube.Setting.Current.Layout;

    ViewBag.Title = "进程模块";

    var isAll = String.Equals("All", Context.Request.GetRequestValue("Mode"), StringComparison.OrdinalIgnoreCase);

    var process = Process.GetCurrentProcess();
    var list = new List<ProcessModule>();
    foreach (ProcessModule item in process.Modules)
    {
        try
        {
            if (isAll || item.FileVersionInfo.CompanyName != "Microsoft Corporation") { list.Add(item); }
        }
        catch { }
    }
}

<div class="layui-fluid" id="mainpage">
    <div class="layui-col-md12">
        <div class="layui-card">
            <div class="layui-card-header">
                进程模块(@process.ProcessName , PID=@process.Id)
                @if (!isAll)
                {
                    <text>（<a href="?Mode=All">完整</a>，仅用户）</text>
                }
                else
                {
                    <text>（完整，<a href="?Mode=OnlyUser">仅用户</a>）</text>
                }
            </div>
            <div class="layui-card-body">
                <div class="layui-form layui-border-box layui-table-view">
                    <div class="layui-table-box" id="AssemblyInfo">
                        <div class="layui-table-header">
                            <table class="layui-table" cellspacing="0" cellpadding="0" border="0" lay-size="sm" style="width:100%">
                                <thead>
                                    <tr>
                                        <th>
                                            <div class="layui-table-cell laytable-cell-1-0-0" data-id="1-0-0">
                                                <span>
                                                    模块名称
                                                </span>
                                            </div>
                                        </th>
                                        <th>
                                            <div class="layui-table-cell laytable-cell-1-0-1" data-id="1-0-1">
                                                <span>
                                                    公司名称
                                                </span>
                                            </div>
                                        </th>
                                        <th>
                                            <div class="layui-table-cell laytable-cell-1-0-2" data-id="1-0-2">
                                                <span>
                                                    产品名称
                                                </span>
                                            </div>
                                        </th>
                                        <th>
                                            <div class="layui-table-cell laytable-cell-1-0-3" data-id="1-0-3">
                                                <span>
                                                    描述
                                                </span>
                                            </div>
                                        </th>
                                        <th>
                                            <div class="layui-table-cell laytable-cell-1-0-4" data-id="1-0-4">
                                                <span>
                                                    版本
                                                </span>
                                            </div>
                                        </th>
                                        <th>
                                            <div class="layui-table-cell laytable-cell-1-0-5" data-id="1-0-5">
                                                <span>
                                                    大小
                                                </span>
                                            </div>
                                        </th>
                                        <th>
                                            <div class="layui-table-cell laytable-cell-1-0-6" data-id="1-0-6">
                                                <span>
                                                    路径
                                                </span>
                                            </div>
                                        </th>
                                    </tr>
                                </thead>
                            </table>
                        </div>
                        <div class="layui-table-body layui-table-main">
                            <table class="layui-table" cellspacing="0" cellpadding="0" border="0" lay-size="sm" style="width:100%">
                                <tbody>
                                    @foreach (ProcessModule item in list)
                                    {
                                        <tr>
                                            <td>
                                                <div class="layui-table-cell laytable-cell-1-0-0" data-id="1-0-0">
                                                    @item.ModuleName
                                                </div>
                                            </td>
                                            <td>
                                                <div class="layui-table-cell laytable-cell-1-0-1" data-id="1-0-1">
                                                    @item.FileVersionInfo.CompanyName
                                                </div>
                                            </td>
                                            <td>
                                                <div class="layui-table-cell laytable-cell-1-0-2" data-id="1-0-2">
                                                    @item.FileVersionInfo.ProductName
                                                </div>
                                            </td>
                                            <td>
                                                <div class="layui-table-cell laytable-cell-1-0-3" data-id="1-0-3">
                                                    @item.FileVersionInfo.FileDescription
                                                </div>
                                            </td>
                                            <td>
                                                <div class="layui-table-cell laytable-cell-1-0-4" data-id="1-0-4">
                                                    @item.FileVersionInfo.FileVersion
                                                </div>
                                            </td>
                                            <td>
                                                <div class="layui-table-cell laytable-cell-1-0-5" data-id="1-0-5">
                                                    @item.ModuleMemorySize
                                                </div>
                                            </td>
                                            <td>
                                                <div class="layui-table-cell laytable-cell-1-0-6" data-id="1-0-6">
                                                    @item.FileName
                                                </div>
                                            </td>
                                        </tr>
                                    }
                                </tbody>
                            </table>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

@section scripts{
    <script>
        layui.use(['jquery'], function () {
            var $ = layui.$;

            setTableScroll();

            setTable();
        });
    </script>
}